/*
 * HWClock.h
 *
 *  Created on: 14.03.2013
 *      Author: mag
 */

#ifndef HWCLOCK_H_
#define HWCLOCK_H_


class HWClock {
public:
	static const int TS_BUFFER_SIZE=24;

	unsigned long _secs;
	unsigned long _usecs;

	HWClock();
	HWClock(long long usecs);

	char *timestamp(char *buffer, size_t bufsize);

	long long usecs() const;
	long long operator -(const HWClock &) const;
	HWClock operator +(long long) const;
	HWClock operator -(long long) const;

	HWClock &operator +=(long long);
	HWClock &operator -=(long long);

	bool operator ==(const HWClock &other) const;
	bool operator !=(const HWClock &other) const;
	bool operator >=(const HWClock &other) const;
	bool operator <=(const HWClock &other) const;
	bool operator <(const HWClock &other) const;
	bool operator >(const HWClock &other) const;

	static void sleep(long long);

	static HWClock now();
};

#endif /* HWCLOCK_H_ */
